﻿<!doctype html>
<html >
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../../css/common.css">
    <link rel="stylesheet" href="../../../css/main.css">
    <script type="text/javascript" src="../../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../../js/colResizable-1.3.min.js"></script>
    <script type="text/javascript" src="../../../js/common.js"></script>
</head>

<body>
<div id="forms" class="mt10">
    <div class="box">
        <div class="box_border">
            <div class="box_top"><b class="pl15">添加文件</b></div>
            <div class="box_center">
                <form action="/wordaddwenjian" class="jqtransform">
                    <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_right">文件名称：</td>
                            <td class="">
                                <input type="text" name="wordName" class="input-text lh30" size="40">
                            </td>
                        </tr>
                        <tr >
                            <td class="td_right">所属文件夹：</td>
                            <td class="">
                                <select name="wordSupId">
                                    <#list allWenJianJia as all>
                                        <option value="${all.wordId}">${all.wordName}</option>
                                    </#list>
                                </select>
                                <#--                    <input type="text" name="wordUrl" class="input-text lh30" size="40">-->
                            </td>
                        </tr>
                        <tr >
                            <td class="td_right">文件类型：</td>
                            <td class="">
                                <input type="text" name="wordType" class="input-text lh30" size="40">
                            </td>
                        </tr>
                        <tr >
                            <td class="td_right">文件上传：</td>
                            <td class="">
                                <#--                    <input type="file" name="name" class="input-text lh30" size="40">-->
                                <#--                    <img id="img" width="100px" src="">-->
                                <input id="tripPic" type="file" class="input-text lh30" size="10" />
                                <button type="button" onclick="uploadPic()" class="btn btn-danger">上传<tton>
                                        <input type="hidden" id="hiddenPic" name="wordUrl">
                                        <span id="picInfo"></span>
                            </td>
                        </tr>

                        <tr>
                            <td class="td_right">创建人：</td>
                            <td><input type="text" value="${user.realName}" name="userName"></td>
                        </tr>
                        <tr>
                            <td class="td_right">备注：</td>
                            <td class="">
                                <textarea class="input-text lh30" name="wordDis"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_right">&nbsp;</td>
                            <td class="">
                                <input type="submit" name="button" class="btn btn82 btn_save2" value="保存">
                                <input type="button" name="button" class="btn btn82 btn_res" onclick="location.href='javascript:history.go(-1)'" value="返回">
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script>
    //上传图片
    function uploadPic() {
        //创建formData对象
        var formData = new FormData();
        formData.append("file",$("#tripPic")[0].files[0]);
        //发送ajax
        $.ajax({
            url: "/workfile",
            data: formData,
            type: "post",
            dataType: "json",
            success: function (result) {
                if (result.code == 0){
                    // alert(result.data.src)
                    //$("#img").attr("src",result.data.src);
                    $("#hiddenPic").val(result.data.src);
                    $("#picInfo").html("上传成功啦！").css("color","green");
                } else {
                    alert(result.msg);
                }
            },
            error: function () {
                alert("您还没有选择文件！")
            },
            contentType: false,
            processData: false
        });
    }

</script>
</html>